<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<link type="text/css" rel="stylesheet" href='<spring:url value="/resources/css/head.css"/>'/>
<html>
<head>
    <title></title>
</head>
<body>
<div class="row">
    <div class="logo"></div>
    <div class="username">
        <span id="showDate"></span>
        <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
        <c:if test="${user.type==0}">
            管理员
        </c:if>
        <c:if test="${user.type==1}">
            值班员
        </c:if>: ${user.name}
        <c:if test="${user.name!=null}">
            <a href="#" id="logout">注销</a>
        </c:if>
    </div>
</div>
</body>
<script>
    $(function () {
        $('#logout').click(function () {
            bootbox.confirm({
                title: "系统提示",
                message: "确认是否退出当前用户？",
                buttons: {
                    cancel: {
                        className: 'btn-sm',
                        label: '<i class="glyphicon glyphicon-remove"></i> 取消'
                    },
                    confirm: {
                        className: 'btn-sm btn-success',
                        label: '<i class="glyphicon glyphicon-ok"></i> 确定'
                    }
                },
                callback: function (result) {
                    if (result) {
                        $("#pwd").val("");
                        $('#dialogConfirmPwd').modal('show');
                        return;
                    }
                }
            });
        });
        $('#exit').click(function () {
            if ($('#pwd').val() == null || $('#pwd').val() == '') {
                bootbox.alert("请输入确认密码！");
            } else {
                var pwd = $('#pwd').val();
                var url = "logout?password=" + pwd;
//                location.href = url;
                $.post(url, function (result) {
                    if (result == "SUCCESS") {
                        location.href = "/GMS/";
                    } else {
                        bootbox.alert("密码不正确");
                    }
                })
            }
        })


        setInterval("getTime()", 1000);
    });
    Date.prototype.Format = function(fmt)
    {
        var o = {
            "M+" : this.getMonth()+1,                 //月份
            "d+" : this.getDate(),                    //日
            "h+" : this.getHours(),                   //小时
            "m+" : this.getMinutes(),                 //分
            "s+" : this.getSeconds(),                 //秒
        };
        if(/(y+)/.test(fmt))
            fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
        for(var k in o)
            if(new RegExp("("+ k +")").test(fmt))
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
        return fmt;
    }
    function getTime() {
        $("#showDate").html(new Date().Format("yyyy-MM-dd hh:mm:ss"));
    }
</script>
</html>
